import static org.junit.Assert.assertEquals;
import org.junit.Test;

public class SimulatorTest {

	@Test
	public void executeSmallTest() {
		
		// start load file
		LoadFile.resetLoadFile();
		LoadFile.startLoadFile("SIM_TEST", 20, 10, 24);
		LoadFile.editLoadAddress(24);
		
		// LC: 20, data: -1
		LoadFile.addTextRecord(20, "FFFFFF", "SIM_TEST");	
		
		// LC 21, data: -8388608
		LoadFile.addTextRecord(21, "800000", "SIM_TEST");	
		
		// LC: 22, data: 200
		LoadFile.addTextRecord(22, "0000C8", "SIM_TEST");	
		
		// LC: 23, data: 5
		LoadFile.addTextRecord(23, "000005", "SIM_TEST");	
		
		// ALT START LOCATION
		// DEBUG ON
		// LC:24, LD-AC 21
		// binary: 000000 0 0 0 1 000 00000010101
		LoadFile.addTextRecord(24, "004015", "SIM_TEST");
		
		// LC: 25, MUL-AC 20 (should cause error)
		// binary: 001010000100000000010100
		LoadFile.addTextRecord(25, "284014", "SIM_TEST");

		// LC: 26, LD-IR 23
		// binary: 000010000100000000010111
		LoadFile.addTextRecord(26,"084017","SIM_TEST");
		
		// LC: 27, SUB-AC 17,IR (should cause error)
		// binary: 001001100100000000010001
		LoadFile.addTextRecord(27,"264011","SIM_TEST");
		
		// LC: 28, ST-AC 23
		// binary: 000001000100000000010111
		LoadFile.addTextRecord(28,"044017","SIM_TEST");
		
		Simulator.execute();
		
		String expected = "800000";
		String actual = Simulator.memory[23];
		
		assertEquals("mem[23] = 800000", expected, actual);
	}
	
	@Test
	public void calculateEffectiveAddress_IRTest(){
		Simulator.index = 50;
		Simulator.base = 25;
		
		// address field contains 500
		Simulator.parsedInstruction[Simulator.address] = "00111110100";
		
		// addrflgs is relative to start
		Simulator.parsedInstruction[Simulator.addrflgs] = "000";
		
		// IR is turned on
		Simulator.parsedInstruction[Simulator.ir] = "1";
		Simulator.parsedInstruction[Simulator.ar] = "0";
		
		Simulator.calculateEffectiveAddress();
		
		int expected = 550;
		int actual = Simulator.effectiveAddress;
		
		assertEquals("effadd should be 550", expected, actual);
	}
	
	@Test
	public void calculateEffectiveAddress_AcutalValueTest(){
		Simulator.index = 50;
		Simulator.base = 25;
		
		// address field contains 500
		Simulator.parsedInstruction[Simulator.address] = "00111110100";
		
		// addrflgs is actual value
		Simulator.parsedInstruction[Simulator.addrflgs] = "111";
		
		Simulator.calculateEffectiveAddress();
		
		int expected = 500;
		int actual = Simulator.effectiveAddress;
		
		assertEquals("effadd should be 500", expected, actual);
	}
	
	@Test 
	public void LDAC(){
		Simulator.effectiveAddress = 1436;
		Simulator.memory[1436] = Simulator.getHexString(1289887);
		
		Simulator.callLDAC();
		
		int expected = 1289887;
		int actual = Simulator.accumulator;
		
		assertEquals("AC = mem[effaddr]", expected, actual);
	}
	
	@Test 
	public void STAC(){
		LoadFile.startLoadFile("test", 0, 4000, 0);
		Simulator.effectiveAddress = 2568;
		Simulator.accumulator = 179828;
		
		Simulator.initializeMemory();
		Simulator.callSTAC();
		
		String expected = Simulator.getHexString(179828);
		String actual = Simulator.memory[2568];
		
		assertEquals("mem[effaddr] = AC", expected, actual);
	}
	
	@Test 
	public void LDIR(){
		Simulator.effectiveAddress = 256;
		Simulator.memory[256] = Simulator.getHexString(128);
		
		Simulator.callLDIR();
		
		int expected = 128;
		int actual = Simulator.index;
		
		assertEquals("IR = mem[effaddr]", expected, actual);
	}
	
	@Test 
	public void STIR(){
		LoadFile.startLoadFile("test", 0, 3000, 0);
		Simulator.effectiveAddress = 2556;
		Simulator.index = 128;
		
		Simulator.initializeMemory();
		Simulator.callSTIR();
		
		String expected = Simulator.getHexString(128);
		String actual = Simulator.memory[2556];
		
		assertEquals("mem[effaddr] = IR", expected, actual);
	}
	
	@Test 
	public void LDAR(){
		Simulator.effectiveAddress = 2596;
		Simulator.memory[2596] = Simulator.getHexString(128);
		
		Simulator.callLDAR();
		
		int expected = 128;
		int actual = Simulator.alternative;
		
		assertEquals("AR = mem[effaddr]", expected, actual);
	}
	
	@Test 
	public void STAR(){
		LoadFile.startLoadFile("test", 500, 4000, 0);
		Simulator.effectiveAddress = 756;
		Simulator.alternative = 1288;
		
		Simulator.initializeMemory();
		Simulator.callSTAR();
		
		String expected = Simulator.getHexString(1288);
		String actual = Simulator.memory[756];
		
		assertEquals("mem[effaddr] = AR", expected, actual);
	}
	
	@Test 
	public void LDBR(){
		Simulator.effectiveAddress = 256;
		Simulator.memory[256] = Simulator.getHexString(128);
		
		Simulator.callLDBR();
		
		int expected = 128;
		int actual = Simulator.base;
		
		assertEquals("BR = mem[effaddr]", expected, actual);
	}
	
	@Test 
	public void STBR(){
		LoadFile.startLoadFile("test", 2000, 4000, 0);
		Simulator.effectiveAddress = 2005;
		Simulator.base = 128;
		
		Simulator.callSTBR();
		
		String expected = Simulator.getHexString(128);
		String actual = Simulator.memory[2005];
		
		assertEquals("mem[effaddr] = BR", expected, actual);
	}
	
	@Test 
	public void ADDAC(){
		Simulator.effectiveAddress = 956;
		Simulator.memory[956] = Simulator.getHexString(-7865935);
		Simulator.accumulator = 7698560;
		
		Simulator.callADDAC();
		
		int expected = 7698560-7865935;
		int actual = Simulator.accumulator;
		
		assertEquals("7698560 + -7865935 = "+expected, expected, actual);
	}
	
	@Test 
	public void ADDAC_Overflow(){
		Simulator.effectiveAddress = 956;
		Simulator.memory[956] = Simulator.getHexString(7698560);
		Simulator.accumulator = 7698560;
		
		// test works but it is commented out because of popups
		// Simulator.callADDAC();
		
		int expected = 7698560;
		int actual = Simulator.accumulator;
		
		assertEquals("AC is unchanged if overflow occurs ", expected, actual);
	}
	
	@Test 
	public void ADDAC_OutOfBounds(){
		Simulator.effectiveAddress = 95600;
		Simulator.memory[956] = Simulator.getHexString(7698560);
		Simulator.accumulator = 7698560;
		
		// test works but it is commented out because of popups
		// Simulator.callADDAC();
		
		int expected = 7698560;
		int actual = Simulator.accumulator;
		
		assertEquals("AC is unchanged if overflow occurs "+expected, expected, actual);
	}
	
	@Test 
	public void SUBAC(){
		Simulator.effectiveAddress = 194;
		Simulator.memory[194] = Simulator.getHexString(-6555555);
		Simulator.index = 1234567;
		
		Simulator.callSUBIR();
		
		int expected = 1234567 + 6555555;
		int actual = Simulator.index;
		
		assertEquals("1234567 - -6555555 = "+expected, expected, actual);
	}
	
	@Test 
	public void SUBAC_Overflow(){
		Simulator.effectiveAddress = 956;
		Simulator.memory[956] = Simulator.getHexString(-7698560);
		Simulator.accumulator = 7698560;
		
		// test works but it is commented out because of popups
		// Simulator.callSUBAC();
		
		int expected = 7698560;
		int actual = Simulator.accumulator;
		
		assertEquals("AC is unchanged if overflow occurs", expected, actual);
	}
	
	@Test 
	public void MULAC(){
		Simulator.effectiveAddress = 94;
		Simulator.memory[94] = Simulator.getHexString(-9656);
		Simulator.index = -200;
		
		Simulator.callMULIR();
		
		int expected = 200 * 9656;
		int actual = Simulator.index;
		
		assertEquals("-200 * -9656 = "+expected, expected, actual);
	}
	@Test 
	public void MULAC_Overflow(){
		Simulator.effectiveAddress = 956;
		Simulator.memory[956] = Simulator.getHexString(7698560);
		Simulator.accumulator = 7698560;
		
		// test works but it is commented out because of popups
		// Simulator.callMULAC();
		
		int expected = 7698560;
		int actual = Simulator.accumulator;
		
		assertEquals("AC is unchanged if overflow occurs", expected, actual);
	}
	
	@Test 
	public void DIVAC(){
		Simulator.effectiveAddress = 89;
		Simulator.memory[89] = Simulator.getHexString(-5);
		Simulator.index = -7817490;
		
		Simulator.callDIVIR();
		
		int expected = 7817490 / 5;
		int actual = Simulator.index;
		
		assertEquals("-7817490 / -5 = "+expected, expected, actual);
	}
	
	@Test 
	public void DIVAC_Overflow(){
		Simulator.effectiveAddress = 956;
		Simulator.memory[956] = Simulator.getHexString(-1);
		Simulator.accumulator = -8388608;
		
		// test works but it is commented out because of popups
		// Simulator.callDIVAC();
		
		int expected = -8388608;
		int actual = Simulator.accumulator;
		
		assertEquals("AC is unchanged if overflow occurs", expected, actual);
	}
	
	@Test 
	public void DIVAC_DivByZero(){
		Simulator.effectiveAddress = 956;
		Simulator.memory[956] = Simulator.getHexString(0);
		Simulator.accumulator = -8388608;
		
		// test works but it is commented out because of popups
		// Simulator.callDIVAC();
		
		int expected = -8388608;
		int actual = Simulator.accumulator;
		
		assertEquals("AC is unchanged if overflow occurs", expected, actual);
	}
	
	@Test 
	public void ADDIR(){
		Simulator.effectiveAddress = 194;
		Simulator.memory[194] = Simulator.getHexString(35);
		Simulator.index = 760;
		
		Simulator.callADDIR();
		
		int expected = 795;
		int actual = Simulator.index;
		
		assertEquals("760 + 35 = 795", expected, actual);
	}
	
	@Test 
	public void SUBIR(){
		Simulator.effectiveAddress = 194;
		Simulator.memory[194] = Simulator.getHexString(65);
		Simulator.index = 500;
		
		Simulator.callSUBIR();
		
		int expected = 435;
		int actual = Simulator.index;
		
		assertEquals("500 - 65 = 435", expected, actual);
	}
	
	@Test 
	public void MULIR(){
		Simulator.effectiveAddress = 94;
		Simulator.memory[94] = Simulator.getHexString(-5);
		Simulator.index = 200;
		
		Simulator.callMULIR();
		
		int expected = -1000;
		int actual = Simulator.index;
		
		assertEquals("200 * -5 = -1000", expected, actual);
	}
	
	@Test 
	public void DIVIR(){
		Simulator.effectiveAddress = 89;
		Simulator.memory[89] = Simulator.getHexString(50);
		Simulator.index = 200;
		
		Simulator.callDIVIR();
		
		int expected = 4;
		int actual = Simulator.index;
		
		assertEquals("200 / 50 = 4", expected, actual);
	}
	
	@Test
	public void ANDAC(){
		Simulator.accumulator = Simulator.getDecimalValue(Simulator.binaryToHex("100110011101011100101111"));
		//					111000111101011110101110
		//					100000011101011100101110
		Simulator.effectiveAddress = 4000;
		Simulator.memory[4000] = Simulator.binaryToHex("111000111101011110101110");
		int expected = Simulator.getDecimalValue(Simulator.binaryToHex("100000011101011100101110"));
		
		Simulator.callANDAC();
		
		int actual = Simulator.accumulator;
		
		assertEquals("AC AND mem[effadd] = 100000011101011100101110", expected, actual);
	}
	
	
	@Test
	public void ORAC(){
		Simulator.accumulator = Simulator.getDecimalValue(Simulator.binaryToHex("100110011101011100101111"));
		//					111000111101011110101110
		//					111110111101011110101111
		Simulator.effectiveAddress = 4000;
		Simulator.memory[4000] = Simulator.binaryToHex("111000111101011110101110");
		int expected = Simulator.getDecimalValue(Simulator.binaryToHex("111110111101011110101111"));
		
		Simulator.callORAC();
		
		int actual = Simulator.accumulator;
		
		assertEquals("AC OR mem[effadd] = 111110111101011110101111", expected, actual);
	}
	
	@Test
	public void LANDACtrue(){
		Simulator.accumulator = 1;
		Simulator.effectiveAddress = 4000;
		Simulator.memory[4000] = Simulator.getHexString(1);
		int expected = 1;
		
		Simulator.callLANDAC();
		
		int actual = Simulator.accumulator;
		
		assertEquals("AC LAND mem[effadd] = 1", expected, actual);
	}
	
	@Test
	public void LANDACfalse(){
		Simulator.accumulator = 1;
		Simulator.effectiveAddress = 4000;
		Simulator.memory[4000] = Simulator.getHexString(-42450);
		int expected = 0;
		
		Simulator.callLANDAC();
		
		int actual = Simulator.accumulator;
		
		assertEquals("AC LAND mem[effadd] = 0", expected, actual);
	}
	
	@Test
	public void LORACtrue(){
		Simulator.accumulator = 1;
		Simulator.effectiveAddress = 4000;
		Simulator.memory[4000] = Simulator.getHexString(450);
		int expected = 1;
		
		Simulator.callLORAC();
		
		int actual = Simulator.accumulator;
		
		assertEquals("AC LOR mem[effadd] = 1", expected, actual);
	}
	
	@Test
	public void LORACfalse(){
		Simulator.accumulator = 0;
		Simulator.effectiveAddress = 4000;
		Simulator.memory[4000] = Simulator.getHexString(450);
		int expected = 0;
		
		Simulator.callLORAC();
		
		int actual = Simulator.accumulator;
		
		assertEquals("AC LOR mem[effadd] = 0", expected, actual);
	}
	@Test
	public void ANDIR(){
		Simulator.index = Simulator.getDecimalValue(Simulator.binaryToHex("100110011101011100101111"));
		//					111000111101011110101110
		//					100000011101011100101110
		Simulator.effectiveAddress = 4000;
		Simulator.memory[4000] = Simulator.binaryToHex("111000111101011110101110");
		int expected = Simulator.getDecimalValue(Simulator.binaryToHex("100000011101011100101110"));
		
		Simulator.callANDIR();
		
		int actual = Simulator.index;
		
		assertEquals("IR AND mem[effadd] = 100000011101011100101110", expected, actual);
	}
	
	
	@Test
	public void ORIR(){
		Simulator.index = Simulator.getDecimalValue(Simulator.binaryToHex("100110011101011100101111"));
		//					111000111101011110101110
		//					111110111101011110101111
		Simulator.effectiveAddress = 4000;
		Simulator.memory[4000] = Simulator.binaryToHex("111000111101011110101110");
		int expected = Simulator.getDecimalValue(Simulator.binaryToHex("111110111101011110101111"));
		
		Simulator.callORIR();
		
		int actual = Simulator.index;
		
		assertEquals("IR OR mem[effadd] = 111110111101011110101111", expected, actual);
	}
	
	@Test
	public void LANDIRtrue(){
		Simulator.index = 1;
		Simulator.effectiveAddress = 4000;
		Simulator.memory[4000] = Simulator.getHexString(1);
		int expected = 1;
		
		Simulator.callLANDIR();
		
		int actual = Simulator.index;
		
		assertEquals("IR LAND mem[effadd] = 1", expected, actual);
	}
	
	@Test
	public void LANDIRfalse(){
		Simulator.index = 1;
		Simulator.effectiveAddress = 4000;
		Simulator.memory[4000] = Simulator.getHexString(-42450);
		int expected = 0;
		
		Simulator.callLANDIR();
		
		int actual = Simulator.index;
		
		assertEquals("IR LAND mem[effadd] = 0", expected, actual);
	}
	
	@Test
	public void LORIRtrue(){
		Simulator.index = 1;
		Simulator.effectiveAddress = 4000;
		Simulator.memory[4000] = Simulator.getHexString(450);
		int expected = 1;
		
		Simulator.callLORIR();
		
		int actual = Simulator.index;
		
		assertEquals("IR LOR mem[effadd] = 1", expected, actual);
	}
	
	@Test
	public void LORIRfalse(){
		Simulator.index = 0;
		Simulator.effectiveAddress = 4000;
		Simulator.memory[4000] = Simulator.getHexString(450);
		int expected = 0;
		
		Simulator.callLORIR();
		
		int actual = Simulator.index;
		
		assertEquals("IR LOR mem[effadd] = 0", expected, actual);
	}
	
	@Test
	public void ANDSR(){
		Simulator.status = "100110011101011100101111".toCharArray();
		//					111000111101011110101110
		//					100000011101011100101110
		Simulator.effectiveAddress = 4000;
		Simulator.memory[4000] = Simulator.binaryToHex("111000111101011110101110");
		int expected = Simulator.getDecimalValue(Simulator.binaryToHex("100000011101011100101110"));
		
		Simulator.callANDSR();
		
		int actual = Simulator.getDecimalValue(Simulator.binaryToHex(new String (Simulator.status)));
		
		assertEquals("SR AND mem[effadd] = 100000011101011100101110", expected, actual);
	}
	
	
	@Test
	public void ORSR(){
		Simulator.status = "100110011101011100101111".toCharArray();
		//					111000111101011110101110
		//					111110111101011110101111
		Simulator.effectiveAddress = 4000;
		Simulator.memory[4000] = Simulator.binaryToHex("111000111101011110101110");
		int expected = Simulator.getDecimalValue(Simulator.binaryToHex("111110111101011110101111"));
		
		Simulator.callORSR();
		
		int actual = Simulator.getDecimalValue(Simulator.binaryToHex(new String (Simulator.status)));
		
		assertEquals("SR OR mem[effadd] = 111110111101011110101111", expected, actual);
	}
	
	@Test
	public void ABSAC(){
		Simulator.accumulator = 7187690;
		
		Simulator.callABSAC();
		
		int expected = 7187690;
		int actual = Simulator.accumulator;
		
		assertEquals("abs(7187690) = 7187690", expected, actual);
	}
	
	@Test
	public void ABSIR(){
		Simulator.index = -15876;
		
		Simulator.callABSIR();
		
		int expected = 15876;
		int actual = Simulator.index;
		
		assertEquals("abs(-15876) = 15876", expected, actual);
	}
	
	@Test
	public void SLAAC(){
		Simulator.accumulator = 5876;
		Simulator.effectiveAddress = 14;
		
		Simulator.callSLAAC();
		
		int expected = Simulator.shiftLeft(5876, 14);
		int actual = Simulator.accumulator;
		
		assertEquals("AC = 5876 shifted left 14 times", expected, actual);
	}
	
	@Test
	public void SLAAC_MoreThan24(){
		Simulator.accumulator = 5876;
		Simulator.effectiveAddress = 34;
		
		// test works. comments out because of pop up errors
		// Simulator.callSLAAC();
		
		int expected = 5876;
		int actual = Simulator.accumulator;
		
		assertEquals("AC is unchagned if shift error occurs", expected, actual);
	}
	
	@Test
	public void SLAAC_LessThanZero(){
		Simulator.accumulator = 5876;
		Simulator.effectiveAddress = -34;
		
		// test works. comments out because of pop up errors
		// Simulator.callSLAAC();
		
		int expected = 5876;
		int actual = Simulator.accumulator;
		
		assertEquals("AC is unchagned if shift error occurs", expected, actual);
	}
	
	@Test
	public void SRAAC(){
		Simulator.accumulator = -400; // 111111111111111110010000
		Simulator.effectiveAddress = 8;
		
		Simulator.callSRAAC();
		
		int expected = -2; // 111111111111111111111110
		int actual = Simulator.accumulator;
		
		assertEquals("AC = 400 shifted right 8 times", expected, actual);
	}
	
	@Test
	public void SLLAC(){
		Simulator.accumulator = 400;
		Simulator.effectiveAddress = 8;
		
		Simulator.callSLLAC();
		
		int expected = Simulator.shiftLeft(400, 8);
		int actual = Simulator.accumulator;
		
		assertEquals("AC = 400 shifted left 8 times", expected, actual);
	}
	
	@Test
	public void SRLAC(){
		Simulator.accumulator = 400;
		Simulator.effectiveAddress = 8;
		
		Simulator.callSRLAC();
		
		int expected = Simulator.shiftRightLogical(400, 8);
		int actual = Simulator.accumulator;
		
		assertEquals("AC = 400 shifted right 8 times", expected, actual);
	}
	@Test
	public void RROTACzero(){
		Simulator.accumulator = 200;
		Simulator.effectiveAddress = 0;
		
		Simulator.callRROTAC();
		
		int expected = 200;
		int actual = Simulator.accumulator;
		
		assertEquals("AC = 200 is unchanged", expected, actual);
	}
	
	@Test
	public void RROTAC(){
		Simulator.accumulator = 200;
		Simulator.effectiveAddress = 12;
		
		Simulator.callRROTAC();
		
		int expected = Simulator.rightRotate(200, 12);
		int actual = Simulator.accumulator;
		
		assertEquals("AC = 200 right rotated 12 times", expected, actual);
	}
	
	@Test
	public void RROTAC_MoreThan24(){
		Simulator.accumulator = 200;
		Simulator.effectiveAddress = 52;
		
		// test works. commented out because of error pop ups
		// Simulator.callRROTAC();
		
		int expected = 200;
		int actual = Simulator.accumulator;
		
		assertEquals("AC = 200 right rotated 12 times", expected, actual);
	}
	
	@Test
	public void RROTAC_LessThanZero(){
		Simulator.accumulator = 200;
		Simulator.effectiveAddress = -12;
		
		// test works. commented out because of error pop ups
		// Simulator.callRROTAC();
		
		int expected = 200;
		int actual = Simulator.accumulator;
		
		assertEquals("AC = 200 right rotated 12 times", expected, actual);
	}
	
	@Test
	public void LROTACzero(){
		Simulator.accumulator = 200;
		Simulator.effectiveAddress = 0;
		
		Simulator.callLROTAC();
		
		int expected = 200;
		int actual = Simulator.accumulator;
		
		assertEquals("AC = 200 is unchanged", expected, actual);
	}
	
	@Test
	public void LROTAC(){
		Simulator.accumulator = 200;
		Simulator.effectiveAddress = 10;
		
		Simulator.callLROTAC();
		
		int expected = Simulator.leftRotate(200, 10);
		int actual = Simulator.accumulator;
		
		assertEquals("AC = 200 rotated left 10 times", expected, actual);
		
	}
	
	@Test
	public void SLAIR(){
		Simulator.index = 400;
		Simulator.effectiveAddress = 19;
		
		Simulator.callSLAIR();
		
		int expected = Simulator.shiftLeft(400, 19);
		int actual = Simulator.index;
		
		assertEquals("IR = 400 shifted left 19 times", expected, actual);
	}
	
	@Test
	public void SRAIR(){
		Simulator.index = -400; // 111111111111111110010000
		Simulator.effectiveAddress = 8;
		
		Simulator.callSRAIR();
		
		int expected = -2; // 111111111111111111111110
		int actual = Simulator.index;
		
		assertEquals("IR = 400 shifted right 8 times", expected, actual);
	}
	
	@Test
	public void SLLIR(){
		Simulator.index = 400;
		Simulator.effectiveAddress = 8;
		
		Simulator.callSLLIR();
		
		int expected = Simulator.shiftLeft(400, 8);
		int actual = Simulator.index;
		
		assertEquals("IR = 400 shifted left 8 times", expected, actual);
	}
	
	@Test
	public void SRLIR(){
		Simulator.index = 400;
		Simulator.effectiveAddress = 8;
		
		Simulator.callSRLIR();
		
		int expected = Simulator.shiftRightLogical(400, 8);
		int actual = Simulator.index;
		
		assertEquals("IR = 400 shifted right 8 times", expected, actual);
	}
	@Test
	public void RROTIRzero(){
		Simulator.index = 200;
		Simulator.effectiveAddress = 0;
		
		Simulator.callRROTIR();
		
		int expected = 200;
		int actual = Simulator.index;
		
		assertEquals("IR = 200 is unchanged", expected, actual);
	}
	
	@Test
	public void RROTIR(){
		Simulator.index = 200;
		Simulator.effectiveAddress = 12;
		
		Simulator.callRROTIR();
		
		int expected = Simulator.rightRotate(200, 12);
		int actual = Simulator.index;
		
		assertEquals("IR = 200 right rotated 12 times", expected, actual);
	}
	
	@Test
	public void LROTIRzero(){
		Simulator.index = 200;
		Simulator.effectiveAddress = 0;
		
		Simulator.callLROTIR();
		
		int expected = 200;
		int actual = Simulator.index;
		
		assertEquals("IR = 200 is unchanged", expected, actual);
	}
	
	@Test
	public void LROTIR(){
		Simulator.index = 200;
		Simulator.effectiveAddress = 10;
		
		Simulator.callLROTIR();
		
		int expected = Simulator.leftRotate(200, 10);
		int actual = Simulator.index;
		
		assertEquals("IR = 200 rotated left 10 times", expected, actual);
		
	}
	
	@Test
	public void LDNACzero(){
		Simulator.effectiveAddress = 7; // 7
		Simulator.memory[Simulator.effectiveAddress] = "000000"; // 0
		
		Simulator.callLDNAC();
		
		int expected = 0;
		int actual = Simulator.accumulator;
		
		assertEquals("AC = 0", expected, actual);
		
	}
	
	@Test
	public void LDNACneg(){
		Simulator.effectiveAddress = 7; // 7
		Simulator.memory[Simulator.effectiveAddress] = "FFFFFF"; // -1
		
		Simulator.callLDNAC();
		
		int expected = 1;
		int actual = Simulator.accumulator;
		
		assertEquals("AC = 1", expected, actual);
		
	}
	
	@Test
	public void LDNACpos(){
		Simulator.effectiveAddress = 7; // 7
		Simulator.memory[Simulator.effectiveAddress] = "001111"; // 4369
		
		Simulator.callLDNAC();
		
		int expected = -4369;
		int actual = Simulator.accumulator;
		
		assertEquals("AC = -4369", expected, actual);
	}
	
	@Test
	public void JMPPRLTtrue(){
		Simulator.parameterListAddress = -49;
		Simulator.location = 25;
		Simulator.effectiveAddress = 50;
		Simulator.status[Simulator.jump] = '0';
		
		Simulator.callJMPPRLT();
		
		int actualLocation = Simulator.location;
		int expectedLocation = 50;
		assertEquals("The location should be 50", actualLocation, expectedLocation);
		
		char actualJumpStatus = Simulator.status[Simulator.jump];
		char expectedJumpStatus = '1';
		assertEquals("The jump status should be on", actualJumpStatus, expectedJumpStatus);
	}
	
	@Test
	public void JMPPRLTfalse(){
		Simulator.parameterListAddress = 7699;
		Simulator.location = 25;
		Simulator.effectiveAddress = 50;
		Simulator.status[Simulator.jump] = '0';
		
		Simulator.callJMPPRLT();
		int actualLocation = Simulator.location;
		int expectedLocation = 25;
		assertEquals("The location should be 25", actualLocation, expectedLocation);
		
		char actualJumpStatus = Simulator.status[Simulator.jump];
		char expectedJumpStatus = '0';
		assertEquals("The jump status should be off", actualJumpStatus, expectedJumpStatus);
	}
	
	@Test
	public void JMPSREQtrue(){
		Simulator.location = 25;
		Simulator.effectiveAddress = 50;
		Simulator.status = "0000000000000000".toCharArray();
		
		Simulator.callJMPSREQ();
		
		int actualLocation = Simulator.location;
		int expectedLocation = 50;
		assertEquals("The location should be 50", actualLocation, expectedLocation);
		
		char actualJumpStatus = Simulator.status[Simulator.jump];
		char expectedJumpStatus = '1';
		assertEquals("The jump status should be on", actualJumpStatus, expectedJumpStatus);
	}
	
	@Test
	public void JMPSREQfalse(){
		Simulator.status[0] = '1';
		Simulator.location = 25;
		Simulator.effectiveAddress = 50;
		Simulator.status[Simulator.jump] = '0';
		
		Simulator.callJMPSREQ();
		
		int actualLocation = Simulator.location;
		int expectedLocation = 25;
		assertEquals("The location should be 25", actualLocation, expectedLocation);
		
		char actualJumpStatus = Simulator.status[Simulator.jump];
		char expectedJumpStatus = '0';
		assertEquals("The jump status should be off", actualJumpStatus, expectedJumpStatus);
	}
	@Test
	public void JMPSRGTtrue(){
		Simulator.status[15] = '1';
		Simulator.status[0] = '0';
		Simulator.location = 25;
		Simulator.effectiveAddress = 50;
		Simulator.status[Simulator.jump] = '0';
		
		Simulator.callJMPSRGT();
		
		int actualLocation = Simulator.location;
		int expectedLocation = 50;
		assertEquals("The location should be 50", actualLocation, expectedLocation);
		
		char actualJumpStatus = Simulator.status[Simulator.jump];
		char expectedJumpStatus = '1';
		assertEquals("The jump status should be on", actualJumpStatus, expectedJumpStatus);
	}
	
	@Test
	public void JMPSRGTfalse(){
		Simulator.location = 25;
		Simulator.effectiveAddress = 50;
		Simulator.status = "1111111000111111".toCharArray();
		
		Simulator.callJMPSRGT();
		
		int actualLocation = Simulator.location;
		int expectedLocation = 25;
		assertEquals("The location should be 25", actualLocation, expectedLocation);
		
		char actualJumpStatus = Simulator.status[Simulator.jump];
		char expectedJumpStatus = '0';
		assertEquals("The jump status should be off", actualJumpStatus, expectedJumpStatus);
	}
	
	@Test
	public void JMPSRLTtrue(){
		Simulator.status[0] = '1';
		Simulator.location = 25;
		Simulator.effectiveAddress = 50;
		Simulator.status[Simulator.jump] = '0';
		
		Simulator.callJMPSRLT();
		
		int actualLocation = Simulator.location;
		int expectedLocation = 50;
		assertEquals("The location should be 50", actualLocation, expectedLocation);
		
		char actualJumpStatus = Simulator.status[Simulator.jump];
		char expectedJumpStatus = '1';
		assertEquals("The jump status should be on", actualJumpStatus, expectedJumpStatus);
	}
	
	@Test
	public void JMPSRLTfalse(){
		Simulator.status[0] = '0';
		Simulator.location = 25;
		Simulator.effectiveAddress = 50;
		Simulator.status[Simulator.jump] = '0';
		
		Simulator.callJMPSRLT();
		int actualLocation = Simulator.location;
		int expectedLocation = 25;
		assertEquals("The location should be 25", actualLocation, expectedLocation);
		
		char actualJumpStatus = Simulator.status[Simulator.jump];
		char expectedJumpStatus = '0';
		assertEquals("The jump status should be off", actualJumpStatus, expectedJumpStatus);
	}
	@Test
	public void JMP(){
		Simulator.location = 25;
		Simulator.effectiveAddress = 50;
		Simulator.status[Simulator.jump] = '0';
		
		Simulator.callJMP();
		
		int actualLocation = Simulator.location;
		int expectedLocation = 50;
		assertEquals("The location should be 50", actualLocation, expectedLocation);
		
		char actualJumpStatus = Simulator.status[Simulator.jump];
		char expectedJumpStatus = '1';
		assertEquals("The jump status should be on", actualJumpStatus, expectedJumpStatus);
	}
	@Test
	public void JMPACGTtrue(){
		Simulator.accumulator = 1;
		Simulator.location = 25;
		Simulator.effectiveAddress = 50;
		Simulator.status[Simulator.jump] = '0';
		
		Simulator.callJMPACGT();
		
		int actualLocation = Simulator.location;
		int expectedLocation = 50;
		assertEquals("The location should be 50", actualLocation, expectedLocation);
		
		char actualJumpStatus = Simulator.status[Simulator.jump];
		char expectedJumpStatus = '1';
		assertEquals("The jump status should be on", actualJumpStatus, expectedJumpStatus);
	}
	
	@Test
	public void JMPACGTfalse(){
		Simulator.accumulator = -8699;
		Simulator.location = 25;
		Simulator.effectiveAddress = 50;
		Simulator.status[Simulator.jump] = '0';
		
		Simulator.callJMPACGT();
		
		int actualLocation = Simulator.location;
		int expectedLocation = 25;
		assertEquals("The location should be 25", actualLocation, expectedLocation);
		
		char actualJumpStatus = Simulator.status[Simulator.jump];
		char expectedJumpStatus = '0';
		assertEquals("The jump status should be off", actualJumpStatus, expectedJumpStatus);
	}

	@Test
	public void JMPACEQtrue(){
		Simulator.accumulator = 0;
		Simulator.location = 25;
		Simulator.effectiveAddress = 50;
		Simulator.status[Simulator.jump] = '0';
		
		Simulator.callJMPACEQ();
		
		int actualLocation = Simulator.location;
		int expectedLocation = 50;
		assertEquals("The location should be 50", actualLocation, expectedLocation);
		
		char actualJumpStatus = Simulator.status[Simulator.jump];
		char expectedJumpStatus = '1';
		assertEquals("The jump status should be on", actualJumpStatus, expectedJumpStatus);
	}
	
	@Test
	public void JMPACEQfalse(){
		Simulator.accumulator = 99;
		Simulator.location = 25;
		Simulator.effectiveAddress = 50;
		Simulator.status[Simulator.jump] = '0';
		
		Simulator.callJMPACEQ();
		
		int actualLocation = Simulator.location;
		int expectedLocation = 25;
		assertEquals("The location should be 25", actualLocation, expectedLocation);
		
		char actualJumpStatus = Simulator.status[Simulator.jump];
		char expectedJumpStatus = '0';
		assertEquals("The jump status should be off", actualJumpStatus, expectedJumpStatus);
	}
	
	@Test
	public void JMPACLTtrue(){
		Simulator.accumulator = -999;
		Simulator.location = 25;
		Simulator.effectiveAddress = 50;
		Simulator.status[Simulator.jump] = '0';
		
		Simulator.callJMPACLT();
		
		int actualLocation = Simulator.location;
		int expectedLocation = 50;
		assertEquals("The location should be 50", actualLocation, expectedLocation);
		
		char actualJumpStatus = Simulator.status[Simulator.jump];
		char expectedJumpStatus = '1';
		assertEquals("The jump status should be on", actualJumpStatus, expectedJumpStatus);
	}
	
	@Test
	public void JMPACLTfalse(){
		Simulator.accumulator = 0;
		Simulator.location = 25;
		Simulator.effectiveAddress = 50;
		Simulator.status[Simulator.jump] = '0';
		
		Simulator.callJMPACLT();
		
		int actualLocation = Simulator.location;
		int expectedLocation = 25;
		assertEquals("The location should be 25", actualLocation, expectedLocation);
		
		char actualJumpStatus = Simulator.status[Simulator.jump];
		char expectedJumpStatus = '0';
		assertEquals("The jump status should be off", actualJumpStatus, expectedJumpStatus);
	}
	
	@Test
	public void JMPIRGTtrue(){
		Simulator.index = 1;
		Simulator.location = 25;
		Simulator.effectiveAddress = 50;
		Simulator.status[Simulator.jump] = '0';
		
		Simulator.callJMPIRGT();
		
		int actualLocation = Simulator.location;
		int expectedLocation = 50;
		assertEquals("The location should be 50", actualLocation, expectedLocation);
		
		char actualJumpStatus = Simulator.status[Simulator.jump];
		char expectedJumpStatus = '1';
		assertEquals("The jump status should be on", actualJumpStatus, expectedJumpStatus);
	}
	
	@Test
	public void JMPIRGTfalse(){
		Simulator.index = -8699;
		Simulator.location = 25;
		Simulator.effectiveAddress = 50;
		Simulator.status[Simulator.jump] = '0';
		
		Simulator.callJMPIRGT();
		
		int actualLocation = Simulator.location;
		int expectedLocation = 25;
		assertEquals("The location should be 25", actualLocation, expectedLocation);
		
		char actualJumpStatus = Simulator.status[Simulator.jump];
		char expectedJumpStatus = '0';
		assertEquals("The jump status should be off", actualJumpStatus, expectedJumpStatus);
	}

	@Test
	public void JMPIREQtrue(){
		Simulator.index = 0;
		Simulator.location = 25;
		Simulator.effectiveAddress = 50;
		Simulator.status[Simulator.jump] = '0';
		
		Simulator.callJMPIREQ();
		
		int actualLocation = Simulator.location;
		int expectedLocation = 50;
		assertEquals("The location should be 50", actualLocation, expectedLocation);
		
		char actualJumpStatus = Simulator.status[Simulator.jump];
		char expectedJumpStatus = '1';
		assertEquals("The jump status should be on", actualJumpStatus, expectedJumpStatus);
	}
	
	@Test
	public void JMPIREQfalse(){
		Simulator.index = 99;
		Simulator.location = 25;
		Simulator.effectiveAddress = 50;
		Simulator.status[Simulator.jump] = '0';
		
		Simulator.callJMPIREQ();
		
		int actualLocation = Simulator.location;
		int expectedLocation = 25;
		assertEquals("The location should be 25", actualLocation, expectedLocation);
		
		char actualJumpStatus = Simulator.status[Simulator.jump];
		char expectedJumpStatus = '0';
		assertEquals("The jump status should be off", actualJumpStatus, expectedJumpStatus);
	}
	
	@Test
	public void JMPIRLTtrue(){
		Simulator.index = -999;
		Simulator.location = 25;
		Simulator.effectiveAddress = 50;
		Simulator.status[Simulator.jump] = '0';
		
		Simulator.callJMPIRLT();
		
		int actualLocation = Simulator.location;
		int expectedLocation = 50;
		assertEquals("The location should be 50", actualLocation, expectedLocation);
		
		char actualJumpStatus = Simulator.status[Simulator.jump];
		char expectedJumpStatus = '1';
		assertEquals("The jump status should be on", actualJumpStatus, expectedJumpStatus);
	}
	
	@Test
	public void JMPIRLTfalse(){
		Simulator.index = 0;
		Simulator.location = 25;
		Simulator.effectiveAddress = 50;
		Simulator.status[Simulator.jump] = '0';
		
		Simulator.callJMPIRLT();
		
		int actualLocation = Simulator.location;
		int expectedLocation = 25;
		assertEquals("The location should be 25", actualLocation, expectedLocation);
		
		char actualJumpStatus = Simulator.status[Simulator.jump];
		char expectedJumpStatus = '0';
		assertEquals("The jump status should be off", actualJumpStatus, expectedJumpStatus);
	}
	
	@Test
	// it works. commented out because of pop up dialog boxes.
	public void DISPLAY2(){
//		LoadFile.startLoadFile("test", 0, 15, 0);
//		Simulator.memory[0] = Simulator.getHexString(0);
//		Simulator.memory[1] = Simulator.getHexString(1);
//		Simulator.memory[2] = Simulator.getHexString(2);
//		Simulator.memory[3] = Simulator.getHexString(3);
//		Simulator.memory[4] = Simulator.getHexString(4);
//		Simulator.memory[5] = Simulator.getHexString(5);
//		Simulator.memory[6] = Simulator.getHexString(6);
//		Simulator.memory[7] = Simulator.getHexString(7);
//		Simulator.memory[8] = Simulator.getHexString(8);
//		Simulator.memory[9] = Simulator.getHexString(9);
//		Simulator.memory[10] = Simulator.getHexString(10);
//		Simulator.memory[11] = Simulator.getHexString(11);
//		Simulator.memory[12] = Simulator.getHexString(12);
//		Simulator.memory[13] = Simulator.getHexString(13);
//		Simulator.memory[14] = Simulator.getHexString(14);
//		Simulator.memory[15] = Simulator.getHexString(15);
//		
//		Simulator.parsedInstruction[Simulator.address] = "10";
//		Simulator.callDISPLAY();
		
		// display should be memory locations 0 through 15 containing 0 through 15 respectively
		
	}
	
	@Test
	// it works. commented out because of pop up dialog boxes.
	public void DISPLAY1(){
//		Simulator.initializeMemory();
//		Simulator.location = 400;
//		Simulator.memory[Simulator.location] = "ABCDEF";
//		
//		Simulator.parsedInstruction[Simulator.address] = "1";
//		Simulator.callDISPLAY();
		
		// The dialog box should say that the location is 190 and the mem[effaddr] is ABCDEF
	}
	
	@Test
	// it works. commented out because of pop up dialog boxes.
	public void DISPLAY0(){
//		Simulator.initializeMemory();
//		Simulator.accumulator = 1;
//		Simulator.base = 1;
//		Simulator.index = 1;
//		Simulator.alternative = 1;
//		Simulator.parameterListAddress = 1;
//		Simulator.status[15] = '1';
//		Simulator.location = 1;
//		Simulator.nextInstruction = 1;
//		Simulator.effectiveAddress = 1;
//		Simulator.instructionWord = "DC0000"; // DISPLAY 0
//		Simulator.parsedInstruction = Simulator.parseInstruction(Simulator.instructionWord);
//		Simulator.memory[Simulator.location] = Simulator.instructionWord;
//		Simulator.callDISPLAY();
		
		// all registers should have ones in them (except instruction word which contains the DISPLAY 0) when the dialog box pops up
	}
	
	@Test
	// it works. commented out because of pop up dialog boxes.
	public void READNUM(){
//		LoadFile.startLoadFile("test", 0, 1, 0);
//		LoadFile.editLoadAddress(0);
//
//		Simulator.effectiveAddress = 0;
//		Simulator.memory[Simulator.effectiveAddress] = "AB6700";
//		
//		Simulator.callREADNUM();
//		
//		String actual = Simulator.memory[Simulator.effectiveAddress];
//		
//		// THIS ONLY WORKS IF YOU TYPE IN 999999 AS INPUT!
//		String expected = "0F423F";
//		assertEquals("The memory at the effective address should be 999999", actual, expected);
	}
	
	@Test
	// it works. commented out because of pop up dialog boxes.
	public void READSTR(){
//		LoadFile.startLoadFile("test", 0, 1, 0);
//		LoadFile.editLoadAddress(0);
//
//		Simulator.effectiveAddress = 0;
//		Simulator.memory[Simulator.effectiveAddress] = "AB6700";
//		
//		Simulator.callREADSTR();
//		
//		String actual = Simulator.memory[Simulator.effectiveAddress];
//		
//		// THIS ONLY WORKS IF YOU TYPE IN ABC AS INPUT!
//		String expected = "414243";
//		
//		assertEquals("The memory at the effective address should be 414243", actual, expected);
	}
	
	@Test
	// it works. commented out because of pop up dialog boxes.
	public void WRITENUMOutOfRange(){
//		Simulator.effectiveAddress = 15900;
//		Simulator.location = 45;
//		Simulator.memory[Simulator.location] = "09BC7";
//		
//		Simulator.callWRITENUM();
//		
//		String location = Simulator.memory[Simulator.location];
//		
//		assertEquals("The memory at the current location should not have changed", location, "09BC7");
	}
	
	@Test
	public void WRITENUM(){
		Simulator.effectiveAddress = 159;
		Simulator.location = 45;
		Simulator.memory[Simulator.location] = "09BC7";
		Simulator.memory[Simulator.effectiveAddress] = "56AB";
		
		Simulator.callWRITENUM();
		
		String location = Simulator.memory[Simulator.location];
		
		assertEquals("The memory at the current location should be 56AB", location, "56AB");
	}
	
	@Test
	public void WRITESTR(){
		Simulator.effectiveAddress = 159;
		Simulator.location = 45;
		Simulator.memory[Simulator.location] = "09BC7";
		Simulator.memory[Simulator.effectiveAddress] = "56AB";
		
		Simulator.callWRITESTR();
		
		String location = Simulator.memory[Simulator.location];
		
		assertEquals("The memory at the current location should be 56AB", location, "56AB");
	}
	
	@Test
	public void LDACADR(){
		Simulator.effectiveAddress = 1559;
		Simulator.callLDACADR();
		
		int expected = 1559;
		int actual = Simulator.accumulator;
		
		assertEquals("The AC should have 1559 in it.", actual, expected);
	}
	
	@Test
	public void LDIRADR(){
		Simulator.effectiveAddress = 4065;
		Simulator.callLDIRADR();
		
		int expected = 4065;
		int actual = Simulator.index;
		
		assertEquals("The IR should have 4065 in it.", actual, expected);
	}
	
	@Test
	public void LDBRADR(){
		Simulator.effectiveAddress = 7;
		Simulator.callLDBRADR();
		
		int expected = 7;
		int actual = Simulator.base;
		
		assertEquals("The BR should have 7 in it.", actual, expected);
	}
	
	@Test
	public void LDPR(){
		Simulator.effectiveAddress = 7;
		Simulator.memory[Simulator.effectiveAddress] = "ABCDEF";
		Simulator.callLDPR();
		
		int expected = Simulator.getDecimalValue("ABCDEF");
		int actual = Simulator.parameterListAddress;
		
		assertEquals("The PR should have the value of ABCDEF in it.", actual, expected);
	}
	
	@Test
	public void and(){
		int testInt1 = Simulator.getDecimalValue(Simulator.binaryToHex("100101110111000110101010"));
		int testInt2 = Simulator.getDecimalValue(Simulator.binaryToHex("101011011011010101100111"));
		int expected = Simulator.getDecimalValue(Simulator.binaryToHex("100001010011000100100010"));
		
		int actual = Simulator.and(testInt1, testInt2);
		
		assertEquals(testInt1 + " AND " + testInt2 + " should be " + expected, expected, actual);
	}
	
	@Test
	public void or(){
		int testInt1 = Simulator.getDecimalValue(Simulator.binaryToHex("100101110111000110101010"));
		int testInt2 = Simulator.getDecimalValue(Simulator.binaryToHex("101011011011010101100111"));
		int expected = Simulator.getDecimalValue(Simulator.binaryToHex("101111111111010111101111"));
		
		int actual = Simulator.or(testInt1, testInt2);
		
		assertEquals(testInt1 + " OR " + testInt2 + " should be " + expected, expected, actual);
	}
	
	@Test
	public void landNoneTrue(){
		int testInt1 = 587;
		int testInt2 = 98732;
		
		int actual = Simulator.land(testInt1, testInt2);
		
		int expected = 0;
		
		assertEquals(testInt1 + " LAND " + testInt2 + " should be " + expected, expected, actual);
	}
	
	@Test
	public void landOneTrue(){
		int testInt1 = 0;
		int testInt2 = 1;
		
		int actual = Simulator.land(testInt1, testInt2);
		
		int expected = 0;
		
		assertEquals(testInt1 + " LAND " + testInt2 + " should be " + expected, expected, actual);
	}
	
	@Test
	public void landBothTrue(){
		int testInt1 = 1;
		int testInt2 = 1;
		
		int actual = Simulator.land(testInt1, testInt2);
		
		int expected = 1;
		
		assertEquals(testInt1 + " LAND " + testInt2 + " should be " + expected, expected, actual);
	}
	
	@Test
	public void lorNoneTrue(){
		int testInt1 = 587;
		int testInt2 = 98732;
		
		int actual = Simulator.lor(testInt1, testInt2);
		
		int expected = 0;
		
		assertEquals(testInt1 + " LOR " + testInt2 + " should be " + expected, expected, actual);
	}
	
	@Test
	public void lorOneTrue(){
		int testInt1 = 58697;
		int testInt2 = 1;
		
		int actual = Simulator.lor(testInt1, testInt2);
		
		int expected = 1;
		
		assertEquals(testInt1 + " LOR " + testInt2 + " should be " + expected, expected, actual);
	}
	
	@Test
	public void lorBothTrue(){
		int testInt1 = 1;
		int testInt2 = 1;
		
		int actual = Simulator.lor(testInt1, testInt2);
		
		int expected = 1;
		
		assertEquals(testInt1 + " LOR " + testInt2 + " should be " + expected, expected, actual);
	}
	
	@Test
	public void absZero(){
		int testInt = 0;
		
		int actual = Simulator.abs(testInt);
		
		int expected = 0;
		
		assertEquals("The absolute value of " + testInt + " should be " + expected, expected, actual);
	}
	
	@Test
	public void absPos(){
		int testInt = 539;
		
		int actual = Simulator.abs(testInt);
		
		int expected = 539;
		
		assertEquals("The absolute value of " + testInt + " should be " + expected, expected, actual);
	}
	
	@Test
	public void absNeg(){
		int testInt = -853;
		
		int actual = Simulator.abs(testInt);
		
		int expected = 853;
		
		assertEquals("The absolute value of " + testInt + " should be " + expected, expected, actual);
	}
	
	@Test
	public void shiftRightArithmeticZero(){
		int testInt = Simulator.getDecimalValue(Simulator.binaryToHex("110111011011101101000101"));
		int shiftNum = 0;
		
		int actual = Simulator.shiftRightArithmetic(testInt, shiftNum);
		
		assertEquals(testInt + " shifted " + shiftNum + " places to the right should be " + testInt, testInt, actual);
	}
	
	@Test
	public void shiftRightArithmetic(){
		int testInt = Simulator.getDecimalValue(Simulator.binaryToHex("101100111011111111000101"));
		int shiftNum = 8;
		
		int actual = Simulator.shiftRightArithmetic(testInt, shiftNum);
		
		int expected = Simulator.getDecimalValue(Simulator.binaryToHex("111111111011001110111111"));
		
		assertEquals(testInt + " arithmetically shifteded " + shiftNum + " places to the rightt should be " + expected, expected, actual);
	}
	
	@Test
	public void shiftRightLogicalZero(){
		int testInt = Simulator.getDecimalValue(Simulator.binaryToHex("110111011011101101000101"));
		int shiftNum = 0;
		
		int actual = Simulator.shiftRightLogical(testInt, shiftNum);
		
		assertEquals(testInt + " shifted " + shiftNum + " places to the right should be " + testInt, testInt, actual);
	}
	
	@Test
	public void shiftRightLogical(){
		int testInt = Simulator.getDecimalValue(Simulator.binaryToHex("110101111011111111000101"));
		int shiftNum = 5;
		
		int actual = Simulator.shiftRightLogical(testInt, shiftNum);
		
		int expected = Integer.parseInt("000001101011110111111110", 2);
		
		assertEquals(testInt + " shifteded " + shiftNum + " places to the rightt should be " + expected, expected, actual);
	}
	
	@Test
	public void shiftLeftZero(){
		int testInt = Simulator.getDecimalValue(Simulator.binaryToHex("110111011011101101000101"));
		int shiftNum = 0;
		
		int actual = Simulator.shiftLeft(testInt, shiftNum);
		
		assertEquals(testInt + " shifted " + shiftNum + " places to the left should be " + testInt, testInt, actual);
	}
	
	@Test
	public void shiftLeft(){
		int testInt = Simulator.getDecimalValue(Simulator.binaryToHex("110101011101101111000101"));
		int shiftNum = 10;
		
		int actual = Simulator.shiftLeft(testInt, shiftNum);
		
		int expected = Simulator.getDecimalValue(Simulator.binaryToHex("011011110001010000000000"));
		
		assertEquals(testInt + " shifteded " + shiftNum + " places to the left should be " + expected, expected, actual);
	}
	
	@Test
	public void rightRotateZero(){
		int testInt = Simulator.getDecimalValue(Simulator.binaryToHex("110111011011101101000101"));
		int rotateNum = 0;
		
		int actual = Simulator.leftRotate(testInt, rotateNum);
		
		assertEquals(testInt + " rotated " + rotateNum + " times should be " + testInt, testInt, actual);
	}
	
	@Test
	public void rightRotate(){
		int testInt = Simulator.getDecimalValue(Simulator.binaryToHex("010111011011101101000101"));
		int rotateNum = 7;
		
		int actual = Simulator.rightRotate(testInt, rotateNum);
		
		int expected = Simulator.getDecimalValue(Simulator.binaryToHex("100010101011101101110110"));
		
		assertEquals(testInt + " rotated " + rotateNum + " times should be " + expected, expected, actual);
	}
	
	@Test
	public void leftRotateZero(){
		int testInt = Simulator.getDecimalValue(Simulator.binaryToHex("110111001101101101010101"));
		int rotateNum = 0;
		
		int actual = Simulator.leftRotate(testInt, rotateNum);
		
		assertEquals(testInt + " rotated " + rotateNum + " times should be " + testInt, testInt, actual);
	}
	
	@Test
	public void leftRotate(){
		int testInt = Simulator.getDecimalValue(Simulator.binaryToHex("110111001101101101010101"));
		int rotateNum = 4;
		
		int actual = Simulator.leftRotate(testInt, rotateNum);
		
		int expected = Simulator.getDecimalValue(Simulator.binaryToHex("110011011011010101011101"));
		
		assertEquals(testInt + " rotated " + rotateNum + " times should be " + expected, expected, actual);
	}
	
	@Test
	public void hexToBianry_BinaryToHex_getHexString_GetDecimalValueTest(){
		// this tests the conversion between binary and hex and the conversion between hex strings and decimal values
		// it works for all numbers in 23 bit 2's compliment but takes forever to run so it is commented out
		
//		for(int i = -8388608; i < 8388608; i ++){
//			int actual = Simulator.getDecimalValue(Simulator.binaryToHex(Simulator.hexToBinary(Simulator.getHexString(i))));
//			System.out.println(i + " = " + actual);
//			assertEquals("i should = actual", i, actual);
//		}
	}
}
